package elitech.vietnam.weatherfashion.weatherservice;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import android.content.Context;

public class KMAService {

	private static final String URL = "http://www.kma.go.kr/weather/forecast/mid-term-rss3.jsp?stnId=108";
	private static final String FILE = "KMAWeather.xml";
	
	public static void getKMAWeatherData(Context context) throws MalformedURLException, IOException {
		BufferedInputStream in = null;
        FileOutputStream fout = null;
        
        in = new BufferedInputStream(new URL(URL).openStream());
        fout = new FileOutputStream(new File(context.getFilesDir(), FILE));

        byte data[] = new byte[1024];
        int count;
        while ((count = in.read(data, 0, 1024)) != -1)
        {
            fout.write(data, 0, count);
        }
        if (in != null)
            in.close();
        if (fout != null)
            fout.close();
	}
	
	public Weather getByCityName() {
		return null;
	}
}
